home *** CD-ROM | disk | FTP | other *** search
- //-------------------------------------------------------------------
- //
- // This code is copyright 2001 by G5 Software.
- // Any unauthorized usage, either in part or in whole of this code
- // is strictly prohibited. Violators WILL be prosecuted to the
- // maximum extent allowed by law.
- //
- //-------------------------------------------------------------------
-
- class CPreventVillageDestructionMission extends
- CBaseMission, CPreventVillageDestructionMissionObjectList, CPreventVillageDestructionMission_Strings, CNavPointUser
- {
- int GetAutoGeneratedUnitsQty()
- {
- return 6;
- }
-
- void CPreventVillageDestructionMission()
- {
- BaseMission_InitMission();
-
- BaseMission_UpdateLoadProgress();
- CreateComponent("DebugCamera", "GameObject", "CDebugCamera");
- SetComponentPosition("DebugCamera",
- matrix(
- 1.0, 0.0, 0.0, 8000.0,
- 0.0, 1.0, 0.0, 8000.0,
- 0.0, 0.0, 1.0, 600.0,
- 0.0, 0.0, 0.0, 1.0
- ));
-
- // CreateComponent(IDToRegister, ComponentID, ScriptName | FileName | "")
- BaseMission_UpdateLoadProgress();
- CreateComponent("Atmosphere", "Atmosphere", "CPreventVillageDestructionMission_Atmosphere");
-
- BaseMission_UpdateLoadProgress();
- CreateComponent("Sky", "SkyObject", "CPreventVillageDestructionMission_Sky");
-
- BaseMission_UpdateLoadProgress();
- CreateComponent("Terrain", "ProgressiveTerrainObject", "CPreventVillageDestructionMission_Terrain");
-
- BaseMission_UpdateLoadProgress();
- CreateComponent("Forest", "Forest", "CPreventVillageDestructionMission_Forest");
-
- BaseMission_UpdateLoadProgress();
- CreateComponent("AIController", "AIController", "CBaseAIController");
-
- BaseMission_CreateObjects();
-
- //
- // Mission specific
- //
-
- // count how many 1st and 2nd objectives' objects are in the mission
- array m_Objects = GetObjectsIDs();
-
- m_EnemiesCount = 0;
- m_StructuresCount = 0;
-
- for (int i = 0; i < m_Objects.size(); i = i + 1)
- {
- if (Core_IsStringStartsWith(m_Objects[i], "Nazi"))
- m_EnemiesCount = m_EnemiesCount + 1;
-
- if (Core_IsStringStartsWith(m_Objects[i], "HQHouse"))
- m_StructuresCount = m_StructuresCount + 1;
- }
-
- m_StructuresDestroyed = 0;
- m_EnemiesDestroyed = 0;
- }
-
- int m_StructuresCount;
- int m_StructuresDestroyed;
-
- int m_EnemiesCount;
- int m_EnemiesDestroyed;
-
- array m_MissionObjectivesStatuses =
- array(
- str_ObjectiveInProgress,
- str_ObjectiveInProgress
- );
-
- array m_BonusMissionObjectivesStatuses =
- array();
-
- //
- // 'virtual' methods
- //
-
- //
- // Mission statistics
-
- string GetMissionStatistics()
- {
- int structures_left = (m_StructuresCount - m_StructuresDestroyed) * 100 / m_StructuresCount;
- int enemies_killed = m_EnemiesDestroyed * 100 / m_EnemiesCount;
-
- string message =
- str_StatisticsTitle_1 + structures_left + "%" + EOLN +
- str_StatisticsTitle_2 + enemies_killed + "%";
-
- return message;
- }
-
- //
- // Mission navpoints
-
- array GetNavPoints()
- {
- array navpoints =
- array(
- GetNavPoint("NavPoint_Vasyki"),
- GetNavPoint("NavPoint_Marshevka"),
- GetNavPoint("NavPoint_Gotovtsevo"),
- GetNavPoint("NavPoint_Barinovo"),
- GetNavPoint("NavPoint_Upyryovka"),
- GetNavPoint("NavPoint_Korzhebino"),
- GetNavPoint("NavPoint_Ovechkino"),
- GetNavPoint("NavPoint_Gerasimovo"),
- GetNavPoint("NavPoint_Ozerino")
- //
- // vector(7967.0, 8364.0, 600.0),
- // vector(2017.0, 3896.0, 0.0),
- // vector(3880.0, 12547.0, 600.0),
- // vector(11864.0, 13886.0, 600.0),
- // vector(11133.0, 11016.0, 600.0),
- // vector(14715.0, 10547.0, 600.0),
- // vector(13622.0, 4694.0, 600.0),
- // vector(11463.0, 3015.0, 600.0),
- // vector(7205.0, 3563.0, 600.0)
- );
- return navpoints;
- }
-
- //
- // Mission map skin file
-
- string GetMapSkinFileName()
- {
- return "Missions/Mission_6/Map.skin";
- }
-
- //
- // Mission specific event handlers
- //
-
- //
- // Object destroyed event handler
- //
-
- void OnGameObjectDestroyed(string _id)
- {
- BaseMission_OnGameObjectDestroyed(_id);
-
- if (Core_IsStringStartsWith(_id, "HQHouse"))
- {
- m_StructuresDestroyed = m_StructuresDestroyed + 1;
-
- int percent_left = (m_StructuresCount - m_StructuresDestroyed) * 100 / m_StructuresCount;
-
- string message = str_WarningMessage + percent_left + "%";
-
- Core_BroadcastEvent(
- "OnDisplayMessage",
- message,
- m_BadNewsColor
- );
- Core_SendEventTo(
- "Helicopter",
- "ShowEventObject",
- _id, // - id of object to show
- 170.0 // - distance from camera to object
- );
- }
-
- // check for failed 1st objective
- if (m_StructuresDestroyed > m_StructuresCount / 2)
- {
- BaseMission_DelayedQuit();
- }
-
- if (Core_IsStringStartsWith(_id, "Nazi"))
- {
- m_EnemiesDestroyed = m_EnemiesDestroyed + 1;
- }
-
- // check for completed 2nd objective
- if (m_EnemiesDestroyed == m_EnemiesCount)
- {
- BaseMission_CompleteObjective(0); // 1st is completed if we haven't exited yet
- BaseMission_CompleteObjective(1);
- }
- }
-
- void OnMissionLoaded()
- {
- Core_SendEventTo("Helicopter", "OnInitiallyEnableTargetScreen", false);
-
- // Start mission music playing
- Core_SendEventTo(SOID_MusicController, "PlayMissionMusic", 6);
- }
- }
-